package com.xl.baseMethod;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;


/**
 * JdkVersion: 1.8
 * Author: lei·xie
 * Created: 2024/8/5 0002 10:22
 * Description: 基本方法 sleep
 */
@Slf4j(topic = "b.Test3")
public class ThreadDemo03 {
    public static void main(String[] args) {
        Thread t1 = new Thread("t1"){
            @Override
            public void run() {
                log.debug("enter sleep");
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    log.debug("wake up..");
                    throw new RuntimeException(e);
                }
            }
        };
        t1.start();
        try {
            //Thread.sleep(1000);
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        log.debug("interrupt");
        t1.interrupt();
    }
}
